import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @User: vitobo
 * @Date: 2024-09-03
 * @Description:
 */
@WebServlet("/hello")
public class HelloServlet extends HttpServlet {
    // 重写init方法
    @Override
    public void init() throws ServletException{
        System.out.println("init");
    }

    // 销毁
    @Override
    public void destroy() {
        System.out.println("destroy");
    }

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("service");
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
                throws ServletException, IOException {

        // 把数据显示到服务器控制台
        System.out.println("hello");
        // 把数据写回到浏览器
        resp.getWriter().write("hello xian");
    }
}





